/**
 * chenuu.com
 * 
 * @author  zhaoxu.com@gmail.com
 * @created 2012-11-3
 */
package com.chenuu.integration.httpclient;


/**
 *
 */
public class RequestParameter implements Comparable<RequestParameter> {

	private String name;
	private String value;

	public RequestParameter(String name, Object value) {
		this.setName(name);
		this.setValue(String.valueOf(value));
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * 排序规则：name优先，value次之。
	 */
	@Override
	public int compareTo(RequestParameter other) {
		if (this.name.equals(other.name)) {
			return this.value.compareTo(other.value);
		}
		return this.name.compareTo(other.name);
	}

	/**
	 * name与value之间用"="连接，即便value为空。
	 */
	@Override
	public String toString() {
		return name + "=" + value;
	}

}
